import sys, os, pygame
from pygame.locals import *

class Character:

    #Set up a character with a certain attributes
    def __init__(self, name1, health, attackPower, defense, img):

        self.img = img    
        self.name = name1
        self.health = health
        self.attackPower = attackPower
        self.defense = defense
        self.dead = False
        #self.magic = magic

    #Set the Character's health to a specified integer
    def setHealth(self, h):

        self.health = h


    #Get the Character's health
    def getHealth(self):

        return self.health


    #Set the Character's attack power
    def setAttackPower(self, a):

        self.attackPower = a


    #Get the Character's attack power
    def getAttackPower(self):

        return self.attackPower


    #Set the Character's defense
    def setDefense(self, d):

        self.defense = d


    #Get the character's defense
    def getDefense(self):

        return self.defense


    #Get the Character's name
    def getName(self):

        return self.name


    #Set the Character's name
    def setName(self, na):

        self.name = na

    #Set the Character Img
    def setImg(self, im):
        
        self.img = im
        
    #get the Character Img
    def getImg(self):
    
        return self.img
    
    #get if a player is dead
    def getDead(self):
        
        return self.dead
    
    def setDead(self):
        
        self.dead = True
    
    #A method to attack another Character
    def attack(self, pl):

        temp = pl.getHealth() - self.attackPower
        pl.setHealth(temp)

        print "----------"
        print ""
        print str(self.getName())+ " attacks " + str(pl.getName())
        print ""
        
        print str(pl.getName()) + " has lost " + str(self.getAttackPower()) + " health points."
        print ""
        print str(pl.getName()) + " now has " + str(pl.getHealth()) + " health points."
        print ""
        print "----------"
        
        self.checkIfDead(pl)

    #A method to check if someone has died   
    def checkIfDead(self, player):
        if player.getHealth() <= 0:
            
            print str(player.getName()) + " has been killed!"
            player.setDead()


    #A method for a special attack
    def specialAttack(self, pl):
        
        temp = pl.getHealth() - self.attackPower * 3
        pl.setHealth(temp)
        
        print "----------"
        print ""
        print str(self.getName())+ " uses his special attack on " + str(pl.getName())
        print ""
        
        print str(pl.getName()) + " has lost " + str(self.getAttackPower() * 3) + " health points."
        print ""
        print str(pl.getName()) + " now has " + str(pl.getHealth()) + " health points."
        print ""
        print "----------"
        
        self.checkIfDead(pl)

    
    #A method to use a magic attack
    def useMagic(self, pl):

        temp = pl.getHealth() - self.magic
        pl.setHealth(temp)
        
 
